# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libsecret
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.18
pkgrel=5
pkgdesc="Library for storing and retrieving passwords and other secrets (mingw-w64)"
arch=('any')
url="https://wiki.gnome.org/Projects/Libsecret"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "intltool")
depends=(${MINGW_PACKAGE_PREFIX}-gcc-libs
         ${MINGW_PACKAGE_PREFIX}-glib2
         ${MINGW_PACKAGE_PREFIX}-libgcrypt)
options=('!libtool' 'strip')
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        0001-port-to.mingw.patch)
sha256sums=('0c73aa762dbd1e38ba7b03de350e23ce818cb810b0784375e95ef61e004b02e3'
            'cd1029a8c1974b616fecea933fdbe5ee3dadc4085268592d4a223cc8ee6b0382')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-port-to.mingw.patch

  autoreconf -fi
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p build-${MINGW_CHOST}
  cd "${srcdir}/build-${MINGW_CHOST}"
  export MSYS2_ARG_CONV_EXCL="-//OASIS//DTD"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --enable-introspection \
    --enable-vala \
    --disable-manpages

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
